<template>
  <div>
    <Dialog class="two-columns setUp" :title="isDetails ? '调拨入库详情' : '调拨入库'" :loading="loading" :visible="visible" :reveal="isDetails ? false : true" @close="handleClose" @confirm="balanceSubmit">
      <el-row>
        <el-col :span="12">调拨单号：{{ currentRow.allotCode }}</el-col>
        <el-col :span="12">调出仓库：{{ currentRow.calloutWriteoffName }}</el-col>
      </el-row>
      <el-row>
        <el-col :span="12">调入仓库：{{ currentRow.mediatorWriteoffName }}</el-col>
        <el-col :span="12">申请人：{{ currentRow.proposerName }}</el-col>
      </el-row>
      <el-table :data="currentRow.allotDetailDto">
        <el-table-column label="名称" prop="materialMedicineName" show-overflow-tooltip />
        <el-table-column label="类型" prop="type" show-overflow-tooltip />
        <el-table-column label="规格" prop="spec" show-overflow-tooltip />
        <el-table-column label="单位" prop="unit" show-overflow-tooltip />
        <el-table-column label="调拨数量" prop="allotNumber" show-overflow-tooltip />
        <el-table-column label="入库数量" min-width="120" prop="mediatorNumber">
          <template slot-scope="{ row }">
            <span v-if="isDetails">{{ row.mediatorNumber }}</span>
            <el-input-number v-if="!isDetails" v-model="row.mediatorNumber" style="width:100px" controls-position="right" :min="row.allotNumber === '0' ? 0 : 1" :max="row.allotNumber - 0" />
          </template>
        </el-table-column>
      </el-table>
      <el-row v-if="isDetails" style="margin-top:20px">
        <el-col :span="12">出库员：{{ currentRow.calloutUsrName }}</el-col>
        <el-col :span="12">出库时间：{{ currentRow.calloutTime }}</el-col>
        <el-col :span="12">入库员：{{ currentRow.mediatorUsrName }}</el-col>
        <el-col :span="12">入库时间：{{ currentRow.mediatorTime }}</el-col>
      </el-row>
      <div v-if="isDetails" class="all-margin-bottom" />
    </Dialog>
  </div>
</template>

<script>
// import { mapMutations } from 'vuex';
import Dialog from "@/components/Dialog";
export default {
  name: "Index",
  components: {
    Dialog,
  },
  props: {
    visible: {
      type: Boolean,
      default: false,
    },
    currentRow: {
      type: Object,
      default: () => {},
    },
    isDetails: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      loading: false,
    };
  },
  methods: {
    async balanceSubmit() {
      this.loading = true;
      const res = await this.$api['warehouse/allocation/putWarehouse']({ ...this.currentRow });
      this.loading = false;
      if (res.code !== 200) return this.$message.error(res.msg);
      this.$message.success("调拨入库成功");
      this.$emit("successHandle");
    },
    handleClose() {
      this.$emit('handleClose');
    },
  },
};
</script>

<style scoped lang='scss'>
/deep/ .el-col{
.el-table .cell{
  height: 32px !important;
  }
}
.el-col{
  line-height: 30px;
}
/deep/.el-table .cell{
  line-height: 30px !important;
}
</style>
